<template>
    <div class="schLine" v-if="!form">
        <div class="itemTitle">{{ title }}</div>
        <el-select :multiple="multiple" v-model="curVal" clearable placeholder="请选择" style="width: 300px">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
        </el-select>
    </div>
    <el-form-item label-width="120px" v-else style="margin:0px 10px" :required="required" :label="title" :prop="field">
        <el-select :multiple="multiple" v-model="curVal" clearable placeholder="请选择" style="width: 300px">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
        </el-select>
    </el-form-item>
    
</template>

<script>
export default {
props: {
    multiple: {
        type: Boolean,
        default: false
    },
    form: {
        type: Boolean,
        default: false
    },
    field: {
        type: String,
        default: ""
    },
    required: {
        type: Boolean,
        default: false
    },
    title: {
        type: String,
        default: "标题"
    },
    value: {
        type: [String, Number],
        default: ""
    },
    opType: {
        type: String,
        default: ""
    }
},

data() {
    return {
        curVal: "",
        options: []
    }
},
created() {
    //查询DB
    this.$sys.getOptions({code: "opCommonDefType"}).then(res => {
        this.options = res.data;
    })
},
watch: {
    value: {
        handler(nv, ov) {
            this.curVal = nv;
        },
        immediate: true
    },
    curVal(nv, ov) {
        this.$emit("input", nv);
    }
}
}
</script>

<style lang="scss" scoped></style>